#!/usr/bin/perl
#
# This code is distributed under the terms of the GPL
#
# (c) Scott Knight 2004
# (c) Tiago Freitas Leal

require '/var/smoothwall/mods/hide_ipsec/modlib.pl';
my $mod = "hide_ipsec";

# # # # # # # # # # # # # # # # # # #
# check for existing installations  #
# # # # # # # # # # # # # # # # # # #

if (-e "/var/smoothwall/mods/$mod/installed") {
	if (! &installed ("/var/smoothwall/mods/$mod/installed", "# Hide IPSEC v1.0")) {
		print "\nPlease install Hide IPSEC v1.0\n";
		print "Note - Run install.pl script.\n \n";
		exit;
	}
}

# # # # # # # # # # # #
# handle file copying #
# # # # # # # # # # # #

#	$storebkp =	where to store backup of the files that are changed by your mod
#	$moddir =	where your mod files are
#	$wkdir =	where you are changing files (backup from and copy to)
#
#	backupinstall ($file, $wkdir, $storebkp, $moddir);
#	backup ($file, $wkdir, $storebkp);
#	install ($file, $wkdir, $moddir);
#	uninstallrestore ($file, $wkdir, $storebkp);
#	uninstall ($file , $wkdir);
#
#	installed ($file, $string);
#
#	search for $string into $file => 1 found / 0 not found

print "Uninstalling and configuring files ...\n";


# # # # # # # # # # # #
# handle file editing #
# # # # # # # # # # # #

my $param = "/var/smoothwall/mods/$mod/params";

&search_replace ("/httpd/cgi-bin/advstatus.cgi", "$param/advstatus.cgi.0.r", "$param/advstatus.cgi.blank.r");
&search_replace ("/httpd/cgi-bin/advstatus.cgi", "$param/advstatus.cgi.3.s", "$param/advstatus.cgi.1.s");
&search_replace ("/httpd/cgi-bin/advstatus.cgi", "$param/advstatus.cgi.4.s", "$param/advstatus.cgi.2.s");



# # # # # # # # # # # #
# handle file linking #
# # # # # # # # # # # #

print "Removing directory \n";
system("/bin/rm -rf /var/smoothwall/mods/$mod");


print "Done\n\n";

# # # #
# end #
# # # #
